<!DOCTYPE html>

<html lang="en">
  <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Phalcon 开发工具（Phalcon Developer Tools） &mdash; Phalcon 2.0.0 文档</title>
    <meta name="keywords" content="php, phalcon, phalcon php, php framework, faster php framework"><link rel="stylesheet" type="text/css" href="../_static/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="http://static.phalconphp.com/css/phalcon.min.css" />
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:700,400' rel='stylesheet' type='text/css'>
    <link href="http://fonts.googleapis.com/css?family=Merriweather:400,700" rel="stylesheet" type="text/css" />
    <!--
    EUROPE <link href='https://fonts.googleapis.com/css?family=Open+Sans:700,400&subset=latin-ext' rel='stylesheet' type='text/css'>
    GREEK <link href='https://fonts.googleapis.com/css?family=Open+Sans:700,400&subset=greek-ext' rel='stylesheet' type='text/css'>
    RUSSIA <link href='https://fonts.googleapis.com/css?family=Open+Sans:700,400&subset=cyrillic-ext,latin' rel='stylesheet' type='text/css'>
    -->

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/docs.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.0.0',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>

    <script src="../_static/jquery.min.js"></script>
    <script type="text/javascript" src="../_static/docs.js"></script>
    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="top" title="Phalcon 2.0.0 文档" href="../index.html" />
    <link rel="next" title="Windows 系统下使用 Phalcon 开发工具（Phalcon Developer Tools on Windows）" href="wintools.html" />
    <link rel="prev" title="调试应用程序（Debugging Applications）" href="debug.html" /> 
  </head>
  <body>

<header class="page-header">
    <nav class="navbar" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-menu-container">
                    <span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
                </button>
                <a class="navbar-brand phalcon-logo" href="/"><span itemprop="name" class="sr-only">Phalcon PHP</span></a>
            </div>

            <div class="collapse navbar-collapse navbar-right" id="main-menu-container">
                <ul class="nav navbar-nav main-menu">
                  <li class="first"><a href="http://phalconphp.com/en/download" class="header-nav-link">Download</a></li>
                  <li><a href="http://docs.phalconphp.com/en/latest/index.html" class="header-nav-link" target="_blank">Documentation</a></li>
                  <li><a href="http://forum.phalconphp.com/" class="header-nav-link" target="_blank">Forum</a></li>
                  <li><a href="http://blog.phalconphp.com/" class="header-nav-link" target="_blank">Blog</a></li>
                  <li><a href="http://phalconphp.com/en/about">About</a></li>
                </ul>
            </div>
        </div>
    </nav>
  </header>

<div class="heading">
    <div class="container">
        <div class="row">
            <h2>Documentation</h2>
        </div>
    </div>
</div>
    <!--<div class="header-line">
      <div class="size-wrap">
        <div class="header-line-title title-white">Documentation</div>
      </div>
    </div>-->
    <div class="related">
      <ul>
        <li class="right" >
          <a href="../genindex.html" title="总目录"
             accesskey="I">索引</a></li>
        <li class="right" >
          <a href="wintools.html" title="Windows 系统下使用 Phalcon 开发工具（Phalcon Developer Tools on Windows）"
             accesskey="N">下一页</a> |</li>
        <li class="right" >
          <a href="debug.html" title="调试应用程序（Debugging Applications）"
             accesskey="P">上一页</a> |</li>
        <li><a href="http://phalconphp.com">Home</a> &raquo;</li>
        <li><a href="../index.html">Phalcon 2.0.0 文档</a> &raquo;</li> 
      </ul>
    </div>  

      <table width="100%" align="center" cellpadding="0" cellspacing="0">
        <tr>
      <td class="primary-box" width="25%" valign="top">
            <div>
            <div id="searchbox" style="">
                <!--<form class="search" action="http://readthedocs.org/search/project/" method="get">
                  <input type="search" name="q" size="25" placeholder="Search">
                  <input type="submit" value="Go">
                  <input type="hidden" name="selected_facets" value="project:">
                </form>-->
                <div style="width:200px;padding:10px">
                  <gcse:searchbox-only></gcse:searchbox-only>
                </div>
            </div>
            </div>
            <div style="padding:5px;padding-left:10px">
              <div id="carbonads-container">
                <div class="carbonad"><div id="azcarbon"></div>
                <script type="text/javascript">var z = document.createElement("script"); z.type = "text/javascript"; z.async = true; z.src = "http://engine.carbonads.com/z/56496/azcarbon_2_1_0_VERT"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(z, s);</script>
                </div></div>
            </div>
            <h3><a href="../index.html">內容目录</a></h3>
            <ul>
<li><a class="reference internal" href="#">Phalcon 开发工具（Phalcon Developer Tools）</a><ul>
<li><a class="reference internal" href="#download">下载（Download）</a><ul>
<li><a class="reference internal" href="#installation">安装（Installation）</a></li>
</ul>
</li>
<li><a class="reference internal" href="#getting-available-commands">获取可用的命令（Getting Available Commands）</a></li>
<li><a class="reference internal" href="#generating-a-project-skeleton">生成项目框架（Generating a Project Skeleton）</a></li>
<li><a class="reference internal" href="#generating-controllers">生成控制器（Generating Controllers）</a></li>
<li><a class="reference internal" href="#preparing-database-settings">数据库配置（Preparing Database Settings）</a></li>
<li><a class="reference internal" href="#generating-models">生成模型（Generating Models）</a></li>
<li><a class="reference internal" href="#crud-scaffold-a-crud">生成基本的 CRUD（Scaffold a CRUD）</a></li>
<li><a class="reference internal" href="#web-web-interface-to-tools">工具的 Web 界面（Web Interface to Tools）</a></li>
<li><a class="reference internal" href="#phpstorm-integrating-tools-with-phpstorm-ide">集成工具到 PhpStorm（Integrating Tools with PhpStorm IDE）</a></li>
<li><a class="reference internal" href="#conclusion">结束语（Conclusion）</a></li>
</ul>
</li>
</ul>

            <h4>上一个主题</h4>
            <p class="topless"><a href="debug.html" title="上一章">&lt; 调试应用程序（Debugging Applications）</a></p>
            <h4>下一个主题</h4>
            <p class="topless"><a href="wintools.html" title="下一章">Windows 系统下使用 Phalcon 开发工具（Phalcon Developer Tools on Windows） &gt;</a></p>
            <h3>本页</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/reference/tools.txt" rel="nofollow">显示源代码</a></li>
            </ul>
        </td>
          <td class="second-box" valign="top">
            <div class="document">
                <div class="documentwrapper">
                  <div class="bodywrapper">
                    <div class="body" >
                      
  <div class="section" id="phalcon-phalcon-developer-tools">
<h1>Phalcon 开发工具（Phalcon Developer Tools）<a class="headerlink" href="#phalcon-phalcon-developer-tools" title="永久链接至标题">¶</a></h1>
<p>Phalcon提供的这个开发工具主要是用来辅助开发，比如生成一些程序的基本框架，生成控制器模型等。使用这个工具我们只需要一个简单的命令即可生成应用的基本框架。</p>
<blockquote class="highlights">
<div><dl class="docutils">
<dt><strong>非常重要:</strong> 要使用这个工具我们必须要安装Phalcon 0.5版本以上的扩展才行。这里我们推荐使用PHP5.3.6或更高版本的PHP. 如果你喜欢使用web版而非console版本的程序，那么在这里</dt>
<dd><a class="reference external" href="http://blog.phalconphp.com/post/23251010409/dont-like-command-line-and-consoles-no-problem">blog post</a> 可以看到更多的内容。</dd>
</dl>
</div></blockquote>
<div class="section" id="download">
<h2>下载（Download）<a class="headerlink" href="#download" title="永久链接至标题">¶</a></h2>
<p>我们可以从 <a class="reference external" href="https://github.com/phalcon/phalcon-devtools">Github</a> 上下载或克隆下来这个跨平台的开发辅助工具。</p>
<div class="section" id="installation">
<h3>安装（Installation）<a class="headerlink" href="#installation" title="永久链接至标题">¶</a></h3>
<p>下面详尽的说明了如何在不同的操作系统平台上安装这个辅助开发工具：</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="wintools.html">Windows 系统下使用 Phalcon 开发工具（Phalcon Developer Tools on Windows）</a></li>
<li class="toctree-l1"><a class="reference internal" href="mactools.html">Mac OS X 系统下使用 Phalcon 开发工具（Phalcon Developer Tools on Mac OS X）</a></li>
<li class="toctree-l1"><a class="reference internal" href="linuxtools.html">Linux 系统下使用 Phalcon 开发工具（Phalcon Developer Tools on Linux）</a></li>
</ul>
</div>
</div>
</div>
<div class="section" id="getting-available-commands">
<h2>获取可用的命令（Getting Available Commands）<a class="headerlink" href="#getting-available-commands" title="永久链接至标题">¶</a></h2>
<p>我们可以在虚拟控制台上输入如下命令：phalcon commands</p>
<div class="highlight-sh"><div class="highlight"><pre><span class="nv">$ </span>phalcon commands

Phalcon DevTools <span class="o">(</span>1.2.3<span class="o">)</span>

Available commands:
  commands <span class="o">(</span><span class="nb">alias </span>of: list, enumerate<span class="o">)</span>
  controller <span class="o">(</span><span class="nb">alias </span>of: create-controller<span class="o">)</span>
  model <span class="o">(</span><span class="nb">alias </span>of: create-model<span class="o">)</span>
  all-models <span class="o">(</span><span class="nb">alias </span>of: create-all-models<span class="o">)</span>
  project <span class="o">(</span><span class="nb">alias </span>of: create-project<span class="o">)</span>
  scaffold
  migration
  webtools
</pre></div>
</div>
</div>
<div class="section" id="generating-a-project-skeleton">
<h2>生成项目框架（Generating a Project Skeleton）<a class="headerlink" href="#generating-a-project-skeleton" title="永久链接至标题">¶</a></h2>
<p>我们可以使用Phalcon开发辅助工具生成预先定义的项目架构。 默认情况下，phalcon开发辅助工具会使用apache的mod_rewrite来生成程序的骨架. 要创建项目我们只需要在我们的
web服务器根目录下输入如下命令：</p>
<div class="highlight-sh"><div class="highlight"><pre><span class="nv">$ </span><span class="nb">pwd</span>

/Applications/MAMP/htdocs

<span class="nv">$ </span>phalcon create-project store
</pre></div>
</div>
<p>执行命令后会生成如下的文档结构的项目：</p>
<div class="figure align-center">
<img alt="../_images/tools-2.png" src="../_images/tools-2.png" />
</div>
<p>我们可以在命令上加 <em>&#8211;help</em> 以显示帮助信息（下面的帮助中的中文是翻译时加上去的）：</p>
<div class="highlight-sh"><div class="highlight"><pre>
</pre></div>
</div>
<p>Phalcon DevTools (1.2.3)</p>
<dl class="docutils">
<dt>Help:</dt>
<dd>Creates a project  创建项目</dd>
<dt>Usage:</dt>
<dd>project [name] [type] [directory] [enable-webtools]</dd>
<dt>Arguments: 参数</dt>
<dd>help  Shows this help text  显示此帮助信息</dd>
<dt>Example 例子</dt>
<dd>phalcon project store simple</dd>
<dt>Options: 选项</dt>
<dd><table class="first last docutils option-list" frame="void" rules="none">
<col class="option" />
<col class="description" />
<tbody valign="top">
<tr><td class="option-group">
<kbd><span class="option">--name</span></kbd></td>
<td>Name of the new project 新项目的名字</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--enable-webtools</span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>Determines if webtools should be enabled [optional] 此选项决定了新的项目中是否使用webtools开发辅助组件</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--directory=<var>s</var></span></kbd></td>
<td>Base path on which project will be created [optional] 在何外创建项目</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--type=<var>s</var></span></kbd></td>
<td>Type of the application to be generated (micro, simple, modules, cli) 应用的种类（微型，简单，多模块，console等）</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--template-path</span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>Specify a template path [optional]  指定模板路径</td></tr>
<tr><td class="option-group" colspan="2">
<kbd><span class="option">--use-config-ini</span></kbd></td>
</tr>
<tr><td>&nbsp;</td><td>Use a ini file as configuration file [optional] 使用ini文件作为配置保存文件</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--trace</span></kbd></td>
<td>Shows the trace of the framework in case of exception. [optional] 出错时是否显示框架的trace信息</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--help</span></kbd></td>
<td>Shows this help 显示帮助</td></tr>
</tbody>
</table>
</dd>
</dl>
<p>我们访问新生成项目的地址显示如下：</p>
<div class="figure align-center">
<img alt="../_images/tools-6.png" src="../_images/tools-6.png" />
</div>
</div>
<div class="section" id="generating-controllers">
<h2>生成控制器（Generating Controllers）<a class="headerlink" href="#generating-controllers" title="永久链接至标题">¶</a></h2>
<p>我们可以使用phalcon create-controller &#8211;name test或phalcon controller &#8211;name test来生成名为test的控制器. 当然要使用此命令当前的执行命令目录必须为已存在的phalcon项目内.</p>
<div class="highlight-sh"><div class="highlight"><pre><span class="nv">$ </span>phalcon create-controller --name <span class="nb">test</span>
</pre></div>
</div>
<p>上面的命令会生成如下代码：</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="k">class</span> <span class="nc">TestController</span> <span class="k">extends</span> <span class="nx">Phalcon\Mvc\Controller</span>
<span class="p">{</span>

    <span class="k">public</span> <span class="k">function</span> <span class="nf">indexAction</span><span class="p">()</span>
    <span class="p">{</span>

    <span class="p">}</span>

<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="preparing-database-settings">
<h2>数据库配置（Preparing Database Settings）<a class="headerlink" href="#preparing-database-settings" title="永久链接至标题">¶</a></h2>
<p>当我们使用phalcon的辅助开发工具生成项目时，则生成的配置信息会被放在 <em>app/config/config.ini</em> 文件内。 我们必须要正确的配置连接信息才可生成模型或基本的CRUD操作。
可以在config.ini中进行修改配置信息：</p>
<div class="highlight-ini"><div class="highlight"><pre><span class="k">[database]</span>
<span class="na">adapter</span>  <span class="o">=</span> <span class="s">Mysql</span>
<span class="na">host</span>     <span class="o">=</span> <span class="s">&quot;127.0.0.1&quot;</span>
<span class="na">username</span> <span class="o">=</span> <span class="s">&quot;root&quot;</span>
<span class="na">password</span> <span class="o">=</span> <span class="s">&quot;secret&quot;</span>
<span class="na">dbname</span>   <span class="o">=</span> <span class="s">&quot;store_db&quot;</span>

<span class="k">[phalcon]</span>
<span class="na">controllersDir</span> <span class="o">=</span> <span class="s">&quot;../app/controllers/&quot;</span>
<span class="na">modelsDir</span>      <span class="o">=</span> <span class="s">&quot;../app/models/&quot;</span>
<span class="na">viewsDir</span>       <span class="o">=</span> <span class="s">&quot;../app/views/&quot;</span>
<span class="na">baseUri</span>        <span class="o">=</span> <span class="s">&quot;/store/&quot;</span>
</pre></div>
</div>
</div>
<div class="section" id="generating-models">
<h2>生成模型（Generating Models）<a class="headerlink" href="#generating-models" title="永久链接至标题">¶</a></h2>
<p>使用phalcon开发辅助工具我们可以有若干种方式来生成模型。 我人可以有选择的生成若干个模型或是全部生成。 亦可以指定生成公有属性或是生成setter和getter方法。</p>
<dl class="docutils">
<dt>Options:</dt>
<dd><table class="first last docutils option-list" frame="void" rules="none">
<col class="option" />
<col class="description" />
<tbody valign="top">
<tr><td class="option-group">
<kbd><span class="option">--name=<var>s</var></span></kbd></td>
<td>Table name 表名</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--schema=<var>s</var></span></kbd></td>
<td>Name of the schema. [optional] schema名</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--namespace=<var>s</var></span></kbd></td>
<td>Model&#8217;s namespace [optional] 模型命名空间</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--get-set</span></kbd></td>
<td>Attributes will be protected and have setters/getters. [optional] 设置字段访问属性为私有 并添加setters/getters方法</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--extends=<var>s</var></span></kbd></td>
<td>Model extends the class name supplied [optional] 指定扩展类名</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--doc</span></kbd></td>
<td>Helps to improve code completion on IDEs [optional] 辅助IDE的自动完成功能</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--directory=<var>s</var></span></kbd></td>
<td>Base path on which project will be created [optional] 项目的根目录</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--force</span></kbd></td>
<td>Rewrite the model. [optional] 重写模型</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--trace</span></kbd></td>
<td>Shows the trace of the framework in case of exception. [optional] 出错时显示框架trace信息</td></tr>
<tr><td class="option-group">
<kbd><span class="option">--mapcolumn</span></kbd></td>
<td>Get some code for map columns. [optional] 生成字映射的代码</td></tr>
</tbody>
</table>
</dd>
</dl>
<p>最简单的生成模型的方式：</p>
<div class="highlight-sh"><div class="highlight"><pre><span class="nv">$ </span>phalcon model products
</pre></div>
</div>
<div class="highlight-sh"><div class="highlight"><pre><span class="nv">$ </span>phalcon model --name tablename
</pre></div>
</div>
<p>所有的字段设置为公有：</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="k">class</span> <span class="nc">Products</span> <span class="k">extends</span> <span class="nx">\Phalcon\Mvc\Model</span>
<span class="p">{</span>

    <span class="sd">/**</span>
<span class="sd">     * @var integer</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="nv">$id</span><span class="p">;</span>

    <span class="sd">/**</span>
<span class="sd">     * @var integer</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="nv">$types_id</span><span class="p">;</span>

    <span class="sd">/**</span>
<span class="sd">     * @var string</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="nv">$name</span><span class="p">;</span>

    <span class="sd">/**</span>
<span class="sd">     * @var string</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="nv">$price</span><span class="p">;</span>

    <span class="sd">/**</span>
<span class="sd">     * @var integer</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="nv">$quantity</span><span class="p">;</span>

    <span class="sd">/**</span>
<span class="sd">     * @var string</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="nv">$status</span><span class="p">;</span>

<span class="p">}</span>
</pre></div>
</div>
<p>我们可以在生成模型时指定 <em>&#8211;get-set</em> 参数以实现对字面的保护， 这样我们可以在setter/getter方法里执行一些业务逻辑。</p>
<div class="highlight-php"><div class="highlight"><pre><span class="cp">&lt;?php</span>

<span class="k">class</span> <span class="nc">Products</span> <span class="k">extends</span> <span class="nx">\Phalcon\Mvc\Model</span>
<span class="p">{</span>

    <span class="sd">/**</span>
<span class="sd">     * @var integer</span>
<span class="sd">     */</span>
    <span class="k">protected</span> <span class="nv">$id</span><span class="p">;</span>

    <span class="sd">/**</span>
<span class="sd">     * @var integer</span>
<span class="sd">     */</span>
    <span class="k">protected</span> <span class="nv">$types_id</span><span class="p">;</span>

    <span class="sd">/**</span>
<span class="sd">     * @var string</span>
<span class="sd">     */</span>
    <span class="k">protected</span> <span class="nv">$name</span><span class="p">;</span>

    <span class="sd">/**</span>
<span class="sd">     * @var string</span>
<span class="sd">     */</span>
    <span class="k">protected</span> <span class="nv">$price</span><span class="p">;</span>

    <span class="sd">/**</span>
<span class="sd">     * @var integer</span>
<span class="sd">     */</span>
    <span class="k">protected</span> <span class="nv">$quantity</span><span class="p">;</span>

    <span class="sd">/**</span>
<span class="sd">     * @var string</span>
<span class="sd">     */</span>
    <span class="k">protected</span> <span class="nv">$status</span><span class="p">;</span>


    <span class="sd">/**</span>
<span class="sd">     * Method to set the value of field id</span>
<span class="sd">     * @param integer $id</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="k">function</span> <span class="nf">setId</span><span class="p">(</span><span class="nv">$id</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">id</span> <span class="o">=</span> <span class="nv">$id</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="sd">/**</span>
<span class="sd">     * Method to set the value of field types_id</span>
<span class="sd">     * @param integer $types_id</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="k">function</span> <span class="nf">setTypesId</span><span class="p">(</span><span class="nv">$types_id</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">types_id</span> <span class="o">=</span> <span class="nv">$types_id</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="o">...</span>

    <span class="sd">/**</span>
<span class="sd">     * Returns the value of field status</span>
<span class="sd">     * @return string</span>
<span class="sd">     */</span>
    <span class="k">public</span> <span class="k">function</span> <span class="nf">getStatus</span><span class="p">()</span>
    <span class="p">{</span>
        <span class="k">return</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">status</span><span class="p">;</span>
    <span class="p">}</span>

<span class="p">}</span>
</pre></div>
</div>
<p>另一个非常好的特性即是在我们多次生成模型时，原有的对模型的更改依然会存在。 这样我们就可以不用担心对模型的属性进行修会被后来再次执模型的生成命令所覆盖。下面的截图显示了这是如何工作的：</p>
<div align="center"><iframe src="http://player.vimeo.com/video/39213020" width="500" height="266" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div></div>
<div class="section" id="crud-scaffold-a-crud">
<h2>生成基本的 CRUD（Scaffold a CRUD）<a class="headerlink" href="#crud-scaffold-a-crud" title="永久链接至标题">¶</a></h2>
<p>使用phalcon开发辅助工具我们可以直接快速的生成一个模型的CRUD操作。 如果我们想快速的生成模型的CRUD操作只需要使用phalcon辅助开发工具的中scaffold命令即可。</p>
<p>代码生成后，你可以根据自己的需要修改生成的代码。很多开发者可能不会去使用这个功能，其实这东西有时不是太好用，很多时候开发者往往会手动的书写相关代码。使用scaffold产生的代码可以
帮助我们理解框架是如何工作的当然也可以帮助我们制作出快速原型来。 下面的截图展示了基于products表的scaffold:</p>
<div class="highlight-sh"><div class="highlight"><pre><span class="nv">$ </span>phalcon scaffold --table-name <span class="nb">test</span>
</pre></div>
</div>
<p>scaffold生成器会在相关的文件夹中生成若干个文档。 下面是所生成文件的概览：</p>
<p>在生成的Products控制器中，我们可以看到一个搜索表单和一个生成新product的链接：</p>
<div class="figure align-center">
<img alt="../_images/tools-10.png" src="../_images/tools-10.png" />
</div>
<p>在创建页面我们可以生成经过验证的Products记录。 Phalcon会自动的验证数据库中的非空字段。</p>
<div class="figure align-center">
<img alt="../_images/tools-11.png" src="../_images/tools-11.png" />
</div>
<p>执行搜索后，分页组件会显示颁后的结果。 我们在结果列表的前面放置Edit或Delete链接，以实现相应的操作。</p>
<div class="figure align-center">
<img alt="../_images/tools-12.png" src="../_images/tools-12.png" />
</div>
</div>
<div class="section" id="web-web-interface-to-tools">
<h2>工具的 Web 界面（Web Interface to Tools）<a class="headerlink" href="#web-web-interface-to-tools" title="永久链接至标题">¶</a></h2>
<p>另外，如果你喜欢我们还可以在生成项目时通过添加参数以实现在项目中使用Phalcon开发工具的web接口。 下面的视频中展示了如何工作的：</p>
<div align="center"><iframe src="http://player.vimeo.com/video/42367665" width="500" height="266" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div></div>
<div class="section" id="phpstorm-integrating-tools-with-phpstorm-ide">
<h2>集成工具到 PhpStorm（Integrating Tools with PhpStorm IDE）<a class="headerlink" href="#phpstorm-integrating-tools-with-phpstorm-ide" title="永久链接至标题">¶</a></h2>
<p>下面的视频中展示了如何在 <a class="reference external" href="http://www.jetbrains.com/phpstorm/">PhpStorm IDE</a> 中集成辅助开发工具。 这个配置步骤也适用于其它的PHP IDE.</p>
<div align="center"><iframe src="http://player.vimeo.com/video/43455647" width="500" height="266" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div></div>
<div class="section" id="conclusion">
<h2>结束语（Conclusion）<a class="headerlink" href="#conclusion" title="永久链接至标题">¶</a></h2>
<p>Phalcon开发辅助工具为我们提供了一种简易的产生应用代码的方法， 这可以减少开发时间及潜在的错误。</p>
</div>
</div>


                    </div>
                  </div>
                </div>
            </div>
          </td>
        </tr>
      </table>
    <div class="related">
      <ul>
        <li class="right" >
          <a href="../genindex.html" title="总目录"
             >索引</a></li>
        <li class="right" >
          <a href="wintools.html" title="Windows 系统下使用 Phalcon 开发工具（Phalcon Developer Tools on Windows）"
             >下一页</a> |</li>
        <li class="right" >
          <a href="debug.html" title="调试应用程序（Debugging Applications）"
             >上一页</a> |</li> 
      </ul>
    </div>

      <div class="prefooter">
  <div class="container">
      <div class="row">
          <div class="col-sm-3 text-right">
              <span>Follow along:</span>
          </div>
          <div class="col-sm-6 text-center">
              <a href="https://twitter.com/phalconphp" alt="Twitter" class="btn-social btn-social-twitter"><i class="icon-twitter"></i></a>
              <a href="https://www.facebook.com/pages/Phalcon-Framework/134230726685897" alt="Facebook" class="btn-social btn-social-facebook"><i class="icon-facebook"></i></a>
              <a href="https://plus.google.com/102376109340560896457" alt="Google+" class="btn-social btn-social-googleplus"><i class="icon-googleplus"></i></a>
              <a href="https://github.com/phalcon/cphalcon" alt="Github" class="btn-social btn-social-github"><i class="icon-github"></i></a>
          </div>
          <div class="col-sm-3">
          </div>
      </div>
  </div>

</div>
<footer class="footer">
  <div class="container">
      <div class="row">
          <div class="col-xs-4 col-sm-3">
              <h4>Download</h4>
              <ul>
                  <li><a href="http://phalconphp.com/download">Installing Phalcon</a></li>
                  <li><a href="http://docs.phalconphp.com/en/latest/index.html" class="header-nav-link" target="_blank">Documentation</a></li>
                  <li><a href="http://api.phalconphp.com">API</a></li>
                  <li><a href="http://docs.phalconphp.com/en/latest/reference/tutorial.html">Tutorial</a></li>
                  <li><a href="http://docs.phalconphp.com/en/latest/reference/tutorial.html#sample-applications">Sample Applications</a></li>
              </ul>
          </div>
          <div class="col-xs-4 col-sm-3">
              <h4>Community</h4>
              <ul>
                  <li><a href="http://forum.phalconphp.com/" class="header-nav-link" target="_blank">Forum</a></li>
                  <li><a href="https://github.com/phalcon/cphalcon">GitHub</a></li>
                  <li><a href="https://github.com/phalcon/cphalcon/issues">Issue Tracker</a></li>
                  <li><a href="http://stackoverflow.com/questions/tagged/phalcon">Stack Overflow</a></li>
                  <li><a href="http://phalconphp.com/en/testimonials">Testimonials</a></li>
                  <li><a href="http://builtwith.phalconphp.com/">Built with Phalcon</a></li>
                  <li><a href="http://store.phalconphp.com/">Store</a></li>
              </ul>
          </div>
          <div class="col-xs-4 col-sm-2">
              <h4>About</h4>
              <ul>
                  <li><a class="link-black" href="http://blog.phalconphp.com/">Blog</a></li>
                  <li><a href="http://phalconphp.com/en/about">About</a></li>
                  <li><a href="http://phalconphp.com/en/team">Team</a></li>
                  <li><a href="http://phalconphp.com/en/roadmap">Roadmap</a></li>
                  <li><a href="http://phalconphp.com/en/donate">Donate</a></li>
                  <li><a href="http://phalconphp.com/en/consulting">Consulting</a></li>
                  <li><a href="http://phalconphp.com/en/hosting">Hosting</a></li>
              </ul>
          </div>
          <div id="license-spaccer" class="visible-xs"></div>
          <div id="license-wrapper" class="col-xs-12 col-sm-4">
              <p class="license">

                  Found a typo or an error? Want to improve this document? The documentation sources are available on <a href="http://github.com/phalcon/docs">Github</a><br>
                  Need support or have questions? Check our <a href="http://forum.phalconphp.com">Forum</a><br>
                  <br>

                  Phalcon Framework is released under the <a href="https://github.com/phalcon/cphalcon/blob/master/docs/LICENSE.md">new BSD license</a>.<br>
                  Except where otherwise noted, content on this site is licensed under the
                    <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 License.</a>

                <div class="design">
                  <span>Designed by:</span>

                  <a href="http://www.fog-city.net/" class="fogcity" target="_blank" title="Fog City Software"><span>Fog City Software</span></a>
              </div>
          </div>
      </div>
  </div>
</footer>

    </div>
    <script type="text/javascript">
    $(window).on("load", function(){
      var cx = '009733439235723428699:lh9ltjgvdz8';
      var gcse = document.createElement('script');
      gcse.type = 'text/javascript';
      gcse.async = true;
      gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx;
      var s = document.getElementsByTagName('script')[0];
      s.parentNode.insertBefore(gcse, s);
    });
    </script>

  </body>
</html>